package com.fsy.fmms.workorder.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fsy.fmms.workorder.domain.WorkOrder;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface WorkOrderMapper extends BaseMapper<WorkOrder> {

    @Select("SELECT w.id, w.type, w.name, w.process_id, w.project, w.create_time, \n" +
            "w.complete_time, w.status, w.cur_user, w.create_user,\n" +
            "u1.USERNAME as create_user_name, u2.USERNAME as cur_user_name\n" +
            "from wb_work_order w\n" +
            "LEFT JOIN t_user u1 ON (u1.USER_ID=w.create_user)\n" +
            "LEFT JOIN t_user u2 ON (u2.USER_ID=w.cur_user)")
    IPage<WorkOrder> findWorkOrders(Page page, @Param("order") WorkOrder order);
}
